<!--_meta 作为公共模版分离出去-->
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="Bookmark" href="/favicon.ico" >
<link rel="Shortcut Icon" href="/favicon.ico" />

<link rel="stylesheet" type="text/css" href="/static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="/static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="/lib/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css" href="/static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="/static/h-ui.admin/css/style.css" />

<title>现场挂号</title>
<meta name="keywords" content="">
<meta name="description" content="">
</head>
<body>
<article class="page-container">
	<form action="/rg/regist" method="post" class="form form-horizontal" id="frmRegist">
		<h1>挂号成功</h1>
		<input class="btn btn-primary radius" type="submit" id="" value="&nbsp;&nbsp;返回&nbsp;&nbsp;">
	</form>
</article>

<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="/lib/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="/static/h-ui/js/H-ui.min.js"></script> 
<script type="text/javascript" src="/static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="/lib/datatables/1.10.15/jquery.dataTables.min.js"></script> 
<script type="text/javascript" src="/lib/laypage/1.2/laypage.js"></script>
<!-- 日期菜单 -->
<script type="text/javascript" src="/lib/My97DatePicker/4.8/WdatePicker.js"></script> 
<!-- 下拉菜单 -->
<script type="text/javascript" src="/ext/selectCity/dept.js"></script> 
<script type="text/javascript" src="/ext/selectCity/dimensions.js"></script>
<script type="text/javascript" src="/ext/selectCity/suggest.js"></script>  

<!-- validate校验 -->
<script type="text/javascript" src="/lib/jquery.validation/1.14.0/jquery.validate.js"></script> 
<script type="text/javascript" src="/lib/jquery.validation/1.14.0/validate-methods.js"></script> 
<script type="text/javascript" src="/lib/jquery.validation/1.14.0/messages_zh.js"></script>


<script type="text/javascript">

//判断当前时间为上午还是下午
function amPm(date){
	return date.getHours()>12?'下午':'上午';
}

//年月日毫秒数
var millYear =1000*60*60*24*365;
var millMonth=1000*60*60*24*30;
var millDate=1000*60*60*24;
//根据出生日期设置年龄
function setAgeByBirthday(txtValue){
	var value="";
	var type="岁";
	if(txtValue != ''){
		//生日日期
		var ymd=txtValue.split('-');
		var birthday=new Date(ymd[0],ymd[1]-1,ymd[2]);
		//当前日期
		var now=new Date();
		now = new Date(now.getFullYear(),now.getMonth(),now.getDate());
		//计算年龄
		var milliseconds = now.getTime() - birthday.getTime();
		value=parseInt(milliseconds/millYear);
		if(value<1){
			value=parseInt(milliseconds/millMonth);
			if(value<1){
				value=parseInt(milliseconds/millDate);
				type="日";
			}
			else{
				type="月";
			}
		}
		else{
			type="岁";
		}
	}
	$('#age').val(value);
	$('#ageType').val(type);
}

//根据年龄设置出生日期
function setBirthdayByAge(txtValue){
	var millNow=new Date().getTime();
	var type=$('#ageType').val();
	if(type=='岁'){
		milliseconds=millNow-txtValue*millYear;
	}
	else if(type=='月'){
		milliseconds=millNow-txtValue*millMonth;
	}
	else{
		milliseconds=millNow-txtValue*millDate;
	}
	$('#birthday').val(dateFormat('yyyy-mm-dd',new Date(milliseconds)));
}

//点击行，当前行的radio获得焦点
function setFouce(node){
	$(node).children().children().first().prop('checked',true);
}
$(function(){
	//校验
	$("#frmRegist").validate({
		rules:{
			realName:{
				required:true,
				minlength:2,
				maxlength:16
			},
			age:{
				required:true,
			},
			deptName:{
				required:true,
			}
		}
	});
	

	$('#registNoon').text(amPm(new Date()));//根据当前时间返回上午/下午
	$('#noon').val(amPm(new Date()));//根据当前时间返回上午/下午

	
	
	//病历查询按钮点击事件
	$('#btnQuery').click(function(){
		//移除校验规则
		$("#realName").rules("remove","required");
		//$('#gender').rules("remove","required");
		$("#age").rules("remove","required");
		$("#deptName").rules("remove","required");
		
		$('#frmRegist').attr('action','/rg/caseInfo');
		$('#frmRegist').submit();
	});
	
	//挂号按钮点击事件
	$('#btnRegist').click(function(){
		//添加校验规则
		$('#realName').rules("add",{
			required: true
		});
		$('#age').rules("add",{
			required: true
		});
		$('#deptName').rules("add",{
			required: true
		});
		
		$('#frmRegist').attr('action','/rg/doRegist');
		$('#frmRegist').submit();
	});
	
	//根据年龄类别，设置出生日期
	$('#ageType').change(function(){
		setBirthdayByAge($('#age').val());
	});
	
	//医生排班列表查询按钮点击事件
	$('#btnQueryScheduling').click(function(){
		//移除校验规则
		$("#realName").rules("remove","required");
		//$("#gender").rules("remove","required");
		$("#age").rules("remove","required");
		$("#deptName").rules("remove","required");
		
		$("#frmRegist").attr("action","/rg/schedulingInfo");
		$("#frmRegist").submit();
	});
	
	
	
	$("#deptName").suggest(commoncitys,{hot_list:commoncitys,dataContainer:'#deptID', attachObject:'#dropdown'});
	
	
	$('.skin-minimal input').iCheck({
		checkboxClass: 'icheckbox-blue',
		radioClass: 'iradio-blue',
		increaseArea: '20%'
	});
	
});

//以下是模板提供的方法
$('.table-sort').dataTable({
	"lengthMenu":[5,10,25,50],//表格左上角的下拉菜单
	"aaSorting": [ [ 1, "desc" ] ],//默认第几列排序
	"bStateSave": true,//状态保存
	"paging":true,//分页
	"searching":true,//查询
	"aoColumnDefs": [
	  //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
	  {"orderable":false,"aTargets":[0,6]}// 不参与排序的列
	]
});

</script> 
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>